<template>
  <div>
<div class="register absolute">
		<div class="shading">
      <div class="tt-name">汇拼团</div>
		</div>
		<div class="whiteBg">
			<div class="title acea-row row-center-wrapper">
				<div class="clr">
					注册账号
				</div>
			</div>
      <div class="list">
				<div class="item">
					<div class="acea-row row-middle">
						<image src="/static/images/phone_1.png"></image>
						<input type="text" placeholder="输入手机号码" v-model="account" />
					</div>
				</div>
				<div class="item">
					<div class="acea-row row-middle">
						<image src="/static/images/code_1.png"></image>
						<input type="password" placeholder="请设置密码" v-model="password" required />
					</div>
				</div>
				<div class="item">
					<div class="acea-row row-middle">
						<image src="/static/images/code_2.png"></image>
						<input type="text" placeholder="填写验证码" class="codeIput" v-model="captcha" />
						<!-- <button class="code" :disabled="disabled" :class="disabled === true ? 'on' : ''" @click="code">
							{{ text }}
						</button> -->
					</div>
				</div>
				<div class="item">
					<div class="acea-row row-middle">
						<image src="/static/images/people.png"></image>
						<input type="text" placeholder="填写您的姓名" v-model="name" />
					</div>
				</div>
				<div class="item">
					<div class="acea-row row-middle">
						<image src="/static/images/invitation_code.png"></image>
						<input type="text" placeholder="填写邀请码" v-model="invCode" />
					</div>
				</div>
			</div>
			
			<div class="logon" @click="register">注册</div>
			<div class="tip">
        <navigator url="/pages/users/login/index">
          	<span class="font-color-red">快速登录</span>
        </navigator>
			</div>
		</div>
		<div class="bottom"></div>
	</div>
  </div>
</template>

<script>
  // import sendVerifyCode from "@/mixins/SendVerifyCode";
  import {
		registerVerify,
		register,
    getUserInfo,
    getTcode
  } from "@/api/user";
  // const BACK_URL = "login_back_url";
  export default {
    // mixins: [sendVerifyCode],
    data() {
      return {
        account:'',
        password:'',
        captcha:'',
        name:'',
        invCode:''
      }
    },
    onLoad() {
      // this.get_inv_code()
    },
    mounted(){
      // this.get_inv_code()
    },
    methods: {
      // get_inv_code() {
      //   getTcode(5).then(res => {
      //     console.log(res);
      //   })
      // },
      // async code() {
			// 	let that = this;
			// 	if (!that.account) return that.$util.Tips({
			// 		title: '请填写手机号码'
			// 	});
			// 	if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.account)) return that.$util.Tips({
			// 		title: '请输入正确的手机号码'
			// 	});
			// 	if (that.formItem == 2) that.type = "register";
				
			// 	await registerVerify({
			// 			phone: that.account,
			// 			type: that.type,
			// 			key: that.keyCode,
			// 			code: that.codeVal
			// 		})
			// 		.then(res => {
			// 			that.$util.Tips({title:res.msg});
			// 			that.sendCode();
			// 		})
			// 		.catch(res => {
			// 			console.log(res,'res')
			// 			that.$util.Tips({title:res});
			// 		});
      // },
      // async register() {
			// 	let that = this;
			// 	if (!that.account) return that.$util.Tips({
			// 		title: '请填写手机号码'
			// 	});
			// 	if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.account)) return that.$util.Tips({
			// 		title: '请输入正确的手机号码'
			// 	});
			// 	if (!that.captcha) return that.$util.Tips({
			// 		title: '请填写验证码'
			// 	});
			// 	if (!/^[\w\d]+$/i.test(that.captcha)) return that.$util.Tips({
			// 		title: '请输入正确的验证码'
			// 	});
			// 	if (!that.password) return that.$util.Tips({
			// 		title: '请填写密码'
			// 	});
			// 	if (!that.name) return that.$util.Tips({
			// 		title: '请填写您的姓名'
			// 	});
			// 	if (!that.invCode) return that.$util.Tips({
			// 		title: '请填写你的邀请码'
			// 	});
			// 	if (/^([0-9]|[a-z]|[A-Z]){0,6}$/i.test(that.password)) return that.$util.Tips({
			// 		title: '您输入的密码过于简单'
			// 	});
			// 	register({
			// 			account: that.account,
			// 			captcha: that.captcha,
			// 			password: that.password,
			// 			spread: that.$Cache.get("spread"),
			// 			invcode: that.invCode,
			// 			name: that.name,
			// 		})
			// 		.then(res => {
			// 			let data = res.data;
			// 			that.$store.commit("LOGIN", {
			// 				'token': data.token,
			// 				'time': data.expires_time - this.$Cache.time()
			// 			});
			// 			const backUrl = that.$Cache.get(BACK_URL) || "/pages/index/index";
			// 			that.$Cache.clear(BACK_URL);
			// 			getUserInfo().then(res => {
			// 				that.$store.commit("SETUID", res.data.uid);
			// 				if (backUrl === '/pages/index/index'  || backUrl ===
			// 					'/pages/user/index') {
					
			// 					uni.switchTab({
			// 						url: backUrl
			// 					});
					
			// 				} else {
			// 					uni.switchTab({
			// 						url: '/pages/index/index'
			// 					});
			// 				}
			// 			})
			// 		})
			// 		.catch(res => {
			// 			that.$util.Tips({
			// 				title: res
			// 			});
			// 		});
			// },
    }
  }
</script>

<style lang="scss" scoped>
	.code img {
		width: 100%;
		height: 100%;
	}

	.acea-row.row-middle {
		input {
			margin-left: 20rpx;
		}
  }
  .clr {
    color: #282828;
  }
</style>